﻿/**
  KCAKCAK   CAKCAKC   AK      CA
 AK        KC     CA  AK    AK
CA         KC     CA  AK  KC
CA         KCAKCAKCA  AKCA
CA         KC     CA  AK  KC
 AK        KC     CA  AK    AK
  KCAKCAK  KC     CA  AK      CA

_________________________________________________________________
 China ataca Kamchatka - copyright 2007(c) Ruben Sainz de la Maza
 
	@class: 	App
	@vertion: 	0.1
	@date:		28/11/07
				
	@language: 	ActionScript 3.0
	@author:	Ruben Sainz de la Maza
			
**/


package com.conelmate.cak
{
	import com.conelmate.util.Trace;
	import com.conelmate.cak.screens.ScreenManager;

	import flash.display.DisplayObject;	
	

	public class App extends Trace
	{
		static internal var	_INSTANCE			:App;				//instancia de esta clase (singleton)		
		static	private var _PARENT				:DisplayObject;		//ref al root
		static	private var _objScreenManager	:ScreenManager;		//ref a ScreenManager

		

//_________________________________________________________________________________ Constructor			
		public function App(enforcer:SingletonEnforcer)
		{
			_isTrace = false;
			mTrace("#App# constructor");
		}
		


//_________________________________________________________________________________ Public Methods

		/**
		 * singleton
		 * devolver una instancia de la clase
		 */	
		public static function getInstance():App
		{
			if(App._INSTANCE == null) App._INSTANCE = new App(new SingletonEnforcer());
			return App._INSTANCE;			
		}
		
		
		/**
		 * inicializar
		 */		
		public function init(parent:DisplayObject = null):void
		{
			mTrace("#App# init");

			_PARENT = parent || _PARENT;
			
			_objScreenManager = ScreenManager.getInstance();
			_objScreenManager.init(_PARENT);
		}
		
		
		/**
		 * destruir objetos y variables
		 */	
		public function destroy():void
		{
			mTrace("#App# destroy");
			_objScreenManager.destroy();
			App._INSTANCE = null;
		}		
		
	}
}

internal class SingletonEnforcer{}